@extends('admin.layouts.app')
@section('css')
@endsection

@section('content')
<div class="">
	<div class="page-title">
		<div class="title_left">
			<h3>微信菜单</h3>
		</div>
	</div>

	<div class="clearfix"></div>
	<div class="row">
		<div class="col-md-12 col-sm-12 col-xs-12">
			<div class="x_panel">
				<div class="x_title">
					<h2>编辑菜单</h2>
					<div class="clearfix"></div>
				</div>
				<div class="x_content">
					<br />
					<form class="form-horizontal form-label-left" action="{{route('wechatmenu.update',['id'=>$menu['id']])}}" method="post">
						{{ csrf_field() }}
						{{ method_field('PATCH') }}
						<input type="hidden" name="id" value="{{$menu['id']}}" />
						<div class="form-group{{ $errors->has('pid') ? ' has-error' : '' }}">
							<label class="control-label col-md-3 col-sm-3 col-xs-12">父菜单<span class="required">*</span> </label>
							<div class="col-md-6 col-sm-6 col-xs-12">
								<select name="pid" class="form-control" >
									<option value="0" @if((old('pid')?old('pid'):$menu['pid']) == 0) selected  @endif>一级菜单</option>
									@foreach ($parents as $parent)
									   <option value="{{$parent->id}}" @if($parent->id==(old('pid')?old('pid'):$menu['pid'])) selected @endif>{{$parent->name}}</option>
									@endforeach
								</select>
								@if ($errors->has('pid'))
								<span class="help-block"> <strong>{{ $errors->first('pid') }}</strong> </span>
								@endif
							</div>
						</div>
						<div class="form-group{{ $errors->has('name') ? ' has-error' : '' }}">
							<label class="control-label col-md-3 col-sm-3 col-xs-12">标题<span class="required">*</span> </label>
							<div class="col-md-6 col-sm-6 col-xs-12">
								<input type="text" name="name" class="form-control" value="{{old('name')?old('name'):$menu['name']}}">
								@if ($errors->has('name'))
								<span class="help-block"> <strong>{{ $errors->first('name') }}</strong> </span>
								@endif
							</div>
						</div>
						<div class="form-group{{ $errors->has('type') ? ' has-error' : '' }}">
							<label class="control-label col-md-3 col-sm-3 col-xs-12">类型<span class="required">*</span> </label>
							<div class="col-md-6 col-sm-6 col-xs-12">
								<select name="type" class="form-control" >
									<option value="0" @if($menu['type'] == 0) selected @endif >一级菜单无功能</option>
									<option value="1" @if($menu['type'] == 1) selected @endif >URL</option>
								</select>
								@if ($errors->has('type'))
								<span class="help-block"> <strong>{{ $errors->first('type') }}</strong> </span>
								@endif
							</div>
						</div>
						<div class="form-group">
							<label class="control-label col-md-3 col-sm-3 col-xs-12">URL</label>
							<div class="col-md-6 col-sm-6 col-xs-12">
								<input type="text" name="url" class="form-control" value="{{old('url')?old('url'):$menu['url']}}">
							</div>
						</div>
						<div class="form-group{{ $errors->has('sort') ? ' has-error' : '' }}">
							<label class="control-label col-md-3 col-sm-3 col-xs-12">排序</label>
							<div class="col-md-6 col-sm-6 col-xs-12">
								<input type="text" name="sort" class="form-control" value="{{old('sort')?old('sort'):$menu['sort']}}">
								@if ($errors->has('sort'))
								<span class="help-block"> <strong>{{ $errors->first('sort') }}</strong> </span>
								@endif
							</div>
						</div>
						
						
						<div class="ln_solid"></div>
						<div class="form-group">
							<div class="col-xs-12 text-center">
								<button type="submit" class="btn btn-success">
								提交
								</button>
							</div>
						</div>

					</form>
				</div>
			</div>
		</div>
	</div>
</div>
@endsection

@section('js')
<script src="/admins/vendors/moment/min/moment.min.js"></script>
<script src="/admins/vendors/bootstrap-daterangepicker/daterangepicker.js"></script>
<script type="text/javascript">
	$(function(){
    		var start = moment();
    		var end = moment().add(7, 'days');
		
		$('#failure_date').daterangepicker({
			locale: {
		      format: 'YYYY-MM-DD'
		   	},
		   	minDate:start,
		   	maxDate:end,
          	singleDatePicker: true
       });
	})
</script>
@endsection
